package jmine.tec.persist.diagnostician;

import static bancosys.tec.rtm.diagnostician.AbstractDiagnostician.JMX_DEFAULT_CACHE_DURATION_IN_SECONDS;
import static bancosys.tec.rtm.diagnostician.AbstractDiagnostician.JMX_NAMESPACE;
import static jmine.tec.persist.diagnostician.HibernateStatisticsDiagnostician.NAME;

import org.hibernate.jmx.StatisticsService;
import org.springframework.jmx.export.annotation.ManagedResource;

import bancosys.tec.rtm.diagnostician.AbstractDiagnostician;
import bancosys.tec.rtm.diagnostician.DiagnosisBean;

/**
 * @author Marcio Ribeiro (mmr)
 * @created Dec 16, 2011
 */
@ManagedResource(description = NAME, objectName = JMX_NAMESPACE + ":name=systemUpTime", currencyTimeLimit = JMX_DEFAULT_CACHE_DURATION_IN_SECONDS)
public class HibernateStatisticsDiagnostician extends AbstractDiagnostician {

    public static final String NAME = "Estatísticas do Hibernate";

    private StatisticsService statistics;

    /**
     * @return NAME.
     */
    public String getName() {
        return NAME;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected boolean fillDiagnosisBean(DiagnosisBean bean) throws Exception {
        return true;
    }

    /**
     * @return the statistics
     */
    public StatisticsService getStatistics() {
        return statistics;
    }

    /**
     * @param statistics the statistics to set
     */
    public void setStatistics(StatisticsService statistics) {
        this.statistics = statistics;
    }
}
